<template>
  <div id="app">
    <div class="head">
      <div class="head_content">
        <div class="title_en">Family of Consumer companies</div>
        <div class="title_cn">订单看板</div>
      </div>
    </div>
    <div class="search_bar">
      <div class="search_input" @click="showClassify = true">
        <van-icon name="search" size=".36rem" />
        <input type="text" placeholder="请输入客户名称\产品名称" readonly />
      </div>
      <div class="classify">
        <img src="../../assets/classify.png" @click="showClassify = true" />
      </div>
    </div>
    <div class="order__content">
      <div class="card" :key="index" v-for="(item, index) in list">
        <div class="card_title" v-text="item.contractCode"></div>
        <ul class="card_info">
          <li>客户名称</li>
          <li v-text="item.customerName"></li>
          <li>客户代码</li>
          <li v-text="item.customerCode"></li>
          <li>订单进入系统日期</li>
          <li v-text="item.createTime"></li>
          <li>目的市</li>
          <li v-text="item.goalCity"></li>
        </ul>
        <div class="card_desc_list">
          <div
            class="list_item"
            :key="index"
            v-for="(info, index) in item.skuList"
          >
            <em v-show="index > 0"></em>
            <div class="item_title" v-text="info.productName"></div>
            <ul class="item_info">
              <li>
                <span>产品代码</span><span v-text="info.productCode"></span>
              </li>
              <li>
                <span>发运仓</span><span v-text="info.leaveAdrress"></span>
              </li>
              <li><span>数量</span><span v-text="info.amount"></span></li>
              <li>
                <span>发运时间</span><span v-text="info.leaveTime"></span>
              </li>
              <li><span>单位</span><span v-text="info.unit"></span></li>
              <li>
                <span>预计到货日期</span><span v-text="info.predictTime"></span>
              </li>
              <li><span>件数</span><span v-text="info.amountNumber"></span></li>
              <li><span>签收日期</span><span v-text="info.signTime"></span></li>
              <li><span>状态</span><span v-text="info.orderStatus"></span></li>
              <li><span>SAP单号</span><span v-text="info.sapCode"></span></li>
            </ul>
            <div class="item_remake">
              <span>备注</span
              ><span v-text="info.memo" style="padding-left: .2rem;"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <van-popup v-model="showClassify" round position="bottom">
      <div class="search_content">
        <div class="form_item">
          <div class="select_pop">
            <label>产品名称</label>
            <div @click="showProduct = true">
              <input
                type="text"
                v-model.trim="searchFrom.ProductName"
                placeholder="请输入"
                @input="productInput"
              />
              <van-icon name="arrow-down" size=".24rem" color="#828FB2" />
            </div>
            <ul class="reslist" v-if="productRESList.length > 0">
              <li
                v-for="(item, index) in productRESList"
                :key="index"
                @click="
                  searchFrom.ProductName = item;
                  productRESList = [];
                "
              >
                {{ item }}
              </li>
            </ul>
          </div>
        </div>
        <div class="form_item">
          <div class="select_pop">
            <label>状态</label>
            <div @click="showOrderStatus = true">
              <input
                type="text"
                v-model="searchFrom.OrderStatus"
                readonly="readonly"
                placeholder="请选择"
              />
              <van-icon name="arrow-down" size=".24rem" color="#828FB2" />
            </div>
          </div>
        </div>
        <div class="form_item">
          <div class="select_pop">
            <label>客户名称</label>
            <div @click="showCustomer = true">
              <input
                type="text"
                v-model="searchFrom.CustomerName"
                placeholder="请选择"
                @input="customerInput"
              />
              <van-icon name="arrow-down" size=".24rem" color="#828FB2" />
            </div>
            <ul class="reslist" v-if="customerRESList.length > 0">
              <li
                v-for="(item, index) in customerRESList"
                :key="index"
                @click="
                  searchFrom.CustomerName = item;
                  customerRESList = [];
                "
              >
                {{ item }}
              </li>
            </ul>
          </div>
        </div>
        <!-- <div class="form_item">
                    <div class="select_pop">
                        <label>版本号</label>
                        <div @click="showVersion=true">
                            <input type="text" v-model="searchFrom.Version" readonly="readonly" placeholder="请选择">
                            <van-icon name="arrow-down" size=".24rem" color="#828FB2"/>
                        </div>
                    </div>
                </div> -->
        <div class="form_item" style="text-align: center;margin-top: .2rem;">
          <button class="btn danger" @click="resetFrom">重置</button>
          <button
            class="btn primary"
            @click="
              showClassify = false;
              getList();
            "
          >
            确定
          </button>
        </div>
      </div>
    </van-popup>
    <!-- <van-popup v-model:show="showCustomer" round position="bottom">
            <van-picker
                show-toolbar
                :columns="customerList"
                @cancel="showCustomer = false"
                @confirm="onConfirmCustomer"
            />
        </van-popup> -->
    <van-popup v-model="showOrderStatus" round position="bottom">
      <van-picker
        show-toolbar
        :columns="stateList"
        @cancel="showOrderStatus = false"
        @confirm="onConfirmOrderStatus"
      />
    </van-popup>
    <!-- <van-popup v-model:show="showVersion" round position="bottom">
            <van-picker
                show-toolbar
                :columns="VersionList"
                @cancel="showVersion = false"
                @confirm="onConfirmVersion"
            />
        </van-popup>
        <van-popup v-model:show="showProduct" round position="bottom">
            <van-picker
                show-toolbar
                :columns="productList"
                @cancel="showProduct = false"
                @confirm="onConfirmProduct"
            />
        </van-popup> -->
  </div>
</template>
<script>
import { listVersion, listCustomer, listProduct, list } from "../../api/";
export default {
  name: "orderList",
  data() {
    return {
      searchFrom: {
        ProductName: "",
        CustomerName: "",
        OrderStatus: "",
        Version: ""
      },
      showProduct: false,
      showCustomer: false,
      showOrderStatus: false,
      showVersion: false,
      VersionList: [],
      VersionRESList: [],
      productList: [],
      productRESList: [],
      customerList: [],
      customerRESList: [],
      stateList: ["已签收", "备货中", "已发运", "未备货"],
      showClassify: false,
      list: []
    };
  },
  methods: {
    customerInput() {
      let query = this.searchFrom.CustomerName;
      if (query != "") {
        this.customerRESList = this.customerList.filter(item => {
          return item.toLowerCase().indexOf(query.toLowerCase()) > -1;
        });
      } else {
        this.customerRESList = this.customerList;
      }
    },
    productInput() {
      let query = this.searchFrom.ProductName;
      if (query != "") {
        this.productRESList = this.productList.filter(item => {
          return item.toLowerCase().indexOf(query.toLowerCase()) > -1;
        });
      } else {
        this.productRESList = this.productList;
      }
    },
    VersionInput() {
      let query = this.searchFrom.Version;
      if (query != "") {
        this.VersionRESList = this.VersionList.filter(item => {
          return item.toLowerCase().indexOf(query.toLowerCase()) > -1;
        });
      } else {
        this.VersionRESList = this.VersionList;
      }
    },
    onConfirmClassify() {},
    onConfirmCustomer(selectedOptions) {
      this.searchFrom.CustomerName = selectedOptions;
      this.showCustomer = false;
    },
    onConfirmOrderStatus(selectedOptions) {
      this.searchFrom.OrderStatus = selectedOptions;
      this.showOrderStatus = false;
    },
    onConfirmVersion(selectedOptions) {
      this.searchFrom.Version = selectedOptions;
      this.showVersion = false;
    },
    onConfirmProduct(selectedOptions) {
      this.searchFrom.ProductName = selectedOptions;
      this.showProduct = false;
    },
    resetFrom() {
      this.searchFrom = {
        ProductName: "",
        CustomerName: "",
        OrderStatus: "",
        Version: ""
      };
    },
    getListCustomer() {
      listCustomer({ Satrap: "郭巧娜" }).then(res => {
        this.customerList = res.data;
        this.customerRESList = res.data;
      });
    },
    getListVersion() {
      listVersion({ Satrap: "郭巧娜" }).then(res => {
        this.VersionList = res.data;
        this.VersionRESList = res.data;
      });
    },
    getListProduct() {
      listProduct({ Satrap: "郭巧娜" }).then(res => {
        this.productList = res.data;
        this.productRESList = res.data;
      });
    },
    getList() {
      this.searchFrom.Satrap = "郭巧娜";
      this.searchFrom.pageNum = 1;
      this.searchFrom.pageSize = 10000;
      list(this.searchFrom).then(res => {
        this.list = res.data.list;
      });
    }
  },
  mounted() {
    this.getListCustomer();
    this.getListVersion();
    this.getListProduct();
    this.searchFrom = this.$route.params;
    this.getList();
  }
};
</script>
<style type="text/css" scoped>
#app {
  background: #f4f4f6;
}
.head {
  width: 100%;
  height: 1.66rem;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url(../../assets/order_head.png);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
}
.head .head_content {
  display: flex;
  flex-direction: column;
  padding: 0.2rem 0.3rem;
  justify-content: space-between;
  height: 100%;
}
.head .title_en {
  font-size: 0.24rem;
  font-weight: 400;
  color: #fff;
  /*line-height: 0;*/
}
.head .title_cn {
  font-size: 0.5rem;
  font-weight: 300;
  color: #fff;
  /*line-height: 0;*/
}
.order__content {
  background: #f4f4f6;
  padding: 0.3rem;
  padding-top: 2.6rem;
}
.search_bar {
  width: 100%;
  background: #f4f4f6;
  padding: 0.3rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: fixed;
  top: 1.66rem;
  left: 0;
  right: 0;
  z-index: 5;
}
.search_input {
  width: 6.12rem;
  height: 0.6rem;
  background: #ffffff;
  border-radius: 0.3rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 0.24rem;
}
.search_input input {
  margin-left: 0.24rem;
  height: 0.6rem;
  width: calc(100% - 0.6rem);
  border-width: 0;
  font-size: 0.28rem;
  padding: 0;
}
.classify {
  width: calc(100% - 6.12rem);
  height: 0.48rem;
  text-align: right;
}
.classify img {
  width: 0.48rem;
  height: 0.48rem;
  display: inline-block;
}
.card {
  width: 100%;
  background: #ffffff;
  box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);
  border-radius: 0.16rem;
  padding: 0.24rem;
  margin: 0.3rem 0;
}
.card_title {
  color: #2a2a2a;
  font-size: 0.32rem;
  text-align: center;
  font-weight: bold;
  line-height: 0.6rem;
}
.card_info {
  display: flex;
  flex-wrap: wrap;
  font-weight: bold;
  font-size: 0.28rem;
}
.card_info li {
  width: 50%;
  /*height: .4rem;*/
  line-height: 0.4rem;
  padding-left: 0.16rem;
  margin: 0.1rem 0;
}
.card_info li:nth-child(odd) {
  color: #2a2a2a;
  width: 3.03rem;
}
.card_info li:nth-child(even) {
  color: #7b0000;
  width: calc(100% - 3.03rem);
}
.card_desc_list {
  width: calc(100% - 2px);
  background: #ffffff;
  border-radius: 0.08rem;
  border: 1px solid #171717;
  overflow: auto;
  margin-top: 0.1rem;
}
.list_item {
  width: 100%;
  padding: 0.2rem;
  position: relative;
}
.list_item em {
  width: calc(100% - 0.4rem);
  height: 0;
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0.2rem;
  right: 0.2rem;
  border-top: 1px dashed #707070;
}
.item_title {
  text-align: center;
  color: #2a2a2a;
  font-size: 0.28rem;
  font-weight: 800;
}
.item_info {
  display: flex;
  flex-wrap: wrap;
  font-weight: bold;
  margin-top: 0.2rem;
}
.item_info li:nth-child(odd) {
  width: 2.83rem;
  border-right: 1px solid #707070;
}
.item_info li:nth-child(even) {
  width: calc(100% - 2.83rem);
  padding-left: 0.2rem;
}
.item_info li span {
  display: inline-block;
  width: 50%;
  height: 0.2rem;
  line-height: 0.2rem;
  font-weight: bold;
  font-size: 0.24rem;
  margin: 0.1rem 0;
}
.item_info li span:nth-child(odd) {
  color: #212121;
  /*padding-left: .2rem;*/
}
.item_info li span:nth-child(even) {
  color: #7b0000;
}
.item_info li:nth-child(odd) span:nth-child(odd) {
  width: 1.2rem;
}
.item_info li:nth-child(even) span:nth-child(even) {
  padding-left: 0.1rem;
}
.item_remake {
  height: 0.2rem;
  color: #212121;
  line-height: 0.2rem;
  font-weight: bold;
  font-size: 0.24rem;
  margin: 0.1rem 0;
  /*padding-left: .2rem;*/
}
.search_content {
  padding: 0.2rem 0.54rem 0 0.54rem;
}
.form_item {
  margin: 0.3rem 0;
}
.select_pop {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: relative;
}
.select_pop label {
  width: 1.5rem;
  display: block;
  font-size: 0.28rem;
  font-family: PingFang SC-Bold, PingFang SC;
  font-weight: bold;
  color: #000000;
  line-height: 0px;
}
.select_pop > div {
  width: calc(100% - 1.5rem);
  height: 0.7rem;
  background: #f4f4f6;
  border-radius: 8px 8px 8px 8px;
  opacity: 0.8;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 0.2rem;
}
.reslist {
  z-index: 150;
  display: none;
  position: absolute;
  top: 0.7rem;
  left: 1.5rem;
  background: #fff;
  max-height: 3rem;
  overflow: auto;
  padding: 0.1rem;
  border-radius: 0.16rem;
  box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);
  width: calc(100% - 1.5rem);
}
.reslist li {
  width: 100%;
  display: block;
  font-size: 0.24rem;
  line-height: 0.5rem;
}
.select_pop:hover .reslist {
  display: block;
}
.select_pop div input {
  border: none;
  background: #f4f4f6;
  font-size: 0.24rem;
  width: calc(100% - 0.24rem);
  font-weight: 400;
  height: 100%;
}
.btn {
  display: inline-block;
  width: 2.24rem;
  height: 0.8rem;
  line-height: 0;
  font-size: 0.32rem;
  text-align: center;
  background: #fff;
  border-radius: 0.41rem;
  border: 1px solid #c90000;
  margin: 0 0.35rem;
}
.btn.primary {
  background: #c90000;
  color: #fff;
}
.btn.danger {
  background: #fff;
  color: #c90000;
}
</style>
